package com.smartlink.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.smartlink.app.R;

import java.util.List;

/**
 * Created by Administrator on 2016/7/11.
 */
public class ClassRoomInfoAdapter extends BaseAdapter {
    private Context ctx;
    private List<String[]> list;

    public ClassRoomInfoAdapter(Context ctx, List<String[]> list) {
        this.ctx = ctx;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold viewHold = null;

        if (convertView == null) {
            convertView = LayoutInflater.from(ctx).inflate(R.layout.class_room_list_item, null);
            viewHold = new ViewHold();
            viewHold.tv_class_room_info_name = (TextView) convertView.findViewById(R.id.tv_class_room_info_name);
            convertView.setTag(viewHold);
        } else {
            viewHold = (ViewHold) convertView.getTag();
            viewHold.tv_class_room_info_name.setText(list.get(position)[1]);
        }
        return convertView;
    }

    static class ViewHold {
        TextView tv_class_room_info_name;
    }
}
